package com.fit.dao.language;

import java.util.List;

import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;

import com.fit.entities.Language;



public class LanguageDAOImpl implements LanguageDAO{

	@Inject
	private Session session;
	
	public boolean save(Language newLanguage) {
		if (newLanguage != null) {
			session.save(newLanguage);
			return true;
		}
		return false;
	}

	public List<Language> findAll() {
		return session.createCriteria(Language.class).list();
	}

	public Language findByID(Long id) {
		if (id != null) {
			return (Language) session.get(Language.class, id);
		}
		return null;
	}
	
	public boolean delete(Language language) {

		if (language != null) {
			session.delete(language);
			return true;
		}
		return false;
	}
	
	
	public boolean deleteByID(Long id) {
		Language l = findByID(id);
		if (l != null) {
			delete(l);
			return true;
		}
		return false;
	}

	public boolean update(Language language) {
		if (language != null) {
			session.update(language);
			return true;
		}
		return false;
	}


}
